<!--
    page description : 근태관리 - 입력자 - 근태등록 화면 - 출근입력 (pop_up)
    author      : Yang D
    date        : 2009-01-16
    file name   : attend_open_p.jsp
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
	<s:head theme="ajax" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
	<link rel="stylesheet" type="text/css" href="style/style.css" />
	<script src="inc/js/common.js"></script>
	<title>출근정보 입력</title>
	<script type="text/javascript" language="javascript">
	
	// --------------------J A V A S C R I P T-START-------------------- //
		
		function fnc_submit(f) {
		
			//출근지
			var slIdx 	=	f.check_in_place.selectedIndex;
			var opt		=	f.check_in_place.options[slIdx];
            var i=0;
            var len=f.etc_emp.value.length;
            var temp=f.etc_emp.value
            var cnt=0;
			//직접입력
//			if ( ( (f.check_in_type.value == "0003"  || f.check_in_type.value == "0005" ) && f.etc_emp.value == "") || (opt.value == "3999" && f.etc_emp.value == "")) {
//				alert("<s:text name="alert.message.emptyEtc" />");
//				f.etc_emp.focus();
//				return false;
//			}
			if( ( (f.check_in_type.value == "0003"  || f.check_in_type.value == "0005" ) && f.etc_emp.value == "") || (opt.value == "3999" && f.etc_emp.value == "")){
				alert("<s:text name="alert.message.emptyEtc" />");
				f.etc_emp.focus();
				return false;
			}
	        if( f.check_in_type.value == "0003"  || f.check_in_type.value == "0005"  || opt.value == "3999"){
                 
	                for(i=0;i<len;i++){
                     if(temp.charAt(i)==" "){
                          cnt++;
                        }

	                } 
                     if(len==cnt){
                        alert("비고란에 공백을 허용하지 않습니다.");
                        f.etc_emp.focus();
                        return false;
             		 }
                  
            }
				
	        
			if (confirm("출근유형 :  " + f.check_in_type.options[f.check_in_type.selectedIndex].text + "\n\n출근지    :  " + opt.text+"\n\n비고       :  " + f.etc_emp.value + "  \n\n\n입력하신 출근정보입니다. \n\n확인을 클릭하시면 저장됩니다.")) {
				f.action = "update_emp_check_in.action";		//출근등록
			} else {
				alert("취소되었습니다.");
				return false;
			}
		}
		
		//출근정보 저장시
		// ajax를 적용하여 opener의 죄회 데이터를 바로 적용함.
	    function fnc_apply_change() {
	
	        var rtn_msg = document.getElementById("msg").value;
	        
	        if(rtn_msg.length != 0) {
	            alert(rtn_msg);
	            window.close();
	            opener.call_dojo();
	        }
	        
	    }

	    //현지출근일경우 출근지를 직접입력으로 설정한다.
	    function  fnc_check_type(se) {

	    	//출근유형
			var sIdx	=	se.selectedindex;
			var optInx	=	se.options[sIdx];

			//현지출근
			if (se.value == "0003" || se.value == "0005" ) {	//현지출근 , 오전공가
				
				for ( var i = 0; i < frm_check_in.check_in_place.length; i++) {
					if (frm_check_in.check_in_place.options[i].value == "3999") {
						frm_check_in.check_in_place.options[i].selected = true;
					}
				}
			}
		}
		
	//-- --------------------J A V A S C R I P T-E N D-------------------- //
	</script>
</head>
<body onload="fnc_apply_change()">
	<s:form name="frm_check_in" id="frm_check_in" method="post" theme="simple" onsubmit="return fnc_submit(this)">
		<s:hidden name="yyyymmdd" 		/>		<!-- 기준일자 -->
		<s:hidden name="check_in_time" 	/>		<!-- 출근시간 표시 -->
		<s:hidden name="msg" 			/>		<!-- 저장 메시지 출력 -->
		<s:hidden name="emp_no" 		/>		<!-- 저장 메시지 출력 -->
		<input type="hidden" name="ip" id="ip" value="<%=request.getRemoteAddr() %>" />
	 	<div id="popup_350se_top"></div>
	<div id="popup_350se_bg">
		<div id="popup_325se">
			<div id="popup_325se_box" >
		 		<ul>
					<li class="txt">기준일자</li>
					<li ><s:property value="yyyy_mm_dd" /></li>
				</ul>
				<ul>
					<li class="txt">출근시간</li>
					<li ><s:property value="check_in_time" /></li>
				</ul>
				<ul>
					<li class="txt">출근유형</li>
					<li><s:select name="check_in_type" id="check_in_type" cssClass="combobox120se" list="listCheckInType" listKey="cd" listValue="cd_nm" onchange="fnc_check_type(this)" /></li>
				</ul>
				<ul>
					<li class="txt">출근지</li>
					<li><s:select name="check_in_place" id="check_in_place" cssClass="combobox120se" list="listCheckInPLace" listKey="cd" listValue="cd_nm" /></li>
				</ul>
				<ul>
	    				<li class="txt">비고</li>
	    				<li><s:textfield cssClass="input_200se" maxlength="16" name="etc_emp" value="%{msg_etc_emp}" /></li>
	    			</ul>
			    <div id="popup_btn"><input type="image" value="저장" src="/images/btn_save.gif" style="cursor: pointer;" /></div>
			</div>
		</div>
	</div>
	<!---------------Bottom : STR----------->
	<div id="popup_350se_bottom"><s:submit type="image" src="/images/pop_btn_close.gif" onclick="window.close(); return false;"/></div>
	<!---------------Bottom : END----------->
	</s:form>
</body>
</html>